package com.atguigu.blog.web;

import com.atguigu.blog.dto.response.Result;
import com.atguigu.blog.util.EmailUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("")
public class MailController {

    @GetMapping("/sendtoqq")
    public Result sendtoqq() {
        String[] to = {"1135365441@qq.com", "baidu1135365441@outlook.com"};// 收件人邮箱，支持传
        List<File> files = new ArrayList<>();
        File file = new File("/Users/lizhenghang/Desktop/网上购物系统设计与实现.docx");
        files.add(file);
        EmailUtil.sendMailNoFrom(to, "测试标题to qq", "测试内容to qq", files);
        return Result.ok("发送成功！");
    }

    @GetMapping("/sendto163")
    public Result sendto163() {
        String from = "1135365441@qq.com";// 发件人邮箱
        String[] to = {"18747633468@163.com"};// 收件人邮箱，支持传
        String password = "tynmdlqdelfpjiha";
        String host = "smtp.qq.com";
        List<File> files = new ArrayList<>();
        File file = new File("/Users/lizhenghang/Desktop/网上购物系统设计与实现.docx");
        files.add(file);
        EmailUtil.sendMail(from, to, host, password, "测试标题11111 to 163", "测试内容11111 to 163", files);
        return Result.ok("发送成功！");
    }

}
